package org.gap.jseed.injection;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import org.gap.jseed.injection.annotation.TryCatch;

public class TryCatchInjector extends BaseInjector {

	@Override
	protected Class<TryCatch> getAnnotationType() {
		return TryCatch.class;
	}

	@Override
	protected void injectMethodWithCode(ClassWriter javaWriter, Method method, Annotation annotation) {
		TryCatch tryCatch = (TryCatch)annotation;
		String methodBody = callSuperMethod(method);
		methodBody = tryCatch.handle().surroundBodyWithTryCatch(methodBody);
		javaWriter.writeBody(method, methodBody);
	}
}
